package com.ctgu.project03.utils;

//ThreadLocal工具类
public class BaseContext {
    private static final ThreadLocal<Object> threadLocal = new ThreadLocal<>();

    // 存储键值对
    public static <T> void set(T value){
        threadLocal.set(value);
    }

    // 根据键获取值
    public static <T> T get() {
        return (T) threadLocal.get();
    }

    // 清除ThreadLocal，销毁线程，防止内存泄漏
    public static void remove(){
        threadLocal.remove();
    }
}
